﻿using ControleRepresentante.Data.Catalogs;
using FluentNHibernate.Cfg.Db;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace ControleRepresentante.UnitTests.Mocks
{
    class MockRepositoryProviderConfigurationSqlite : MockRepositoryProviderConfigurationBase
    {
        public MockRepositoryProviderConfigurationSqlite(MockSessionConfiguration sessionConfiguration)
            : base(sessionConfiguration)
        {
        }

        public override IPersistenceConfigurer PersistenceConfigurerGenerator(ICatalog catalog)
        {
            return SQLiteConfiguration.Standard.InMemory()
                .Raw("connection.release_mode", "on_close")
                .ShowSql()
                .QuerySubstitutions("true=1;false=0")
                .Provider(typeof(SqLiteInMemoryTestConnectionProvider).AssemblyQualifiedName)
                .ConnectionString("Data Source=:memory:;Version=3;New=True;Pooling=True;Max Pool Size=1;");
        }

        public override void ExposeConfiguration(Configuration configuration)
        {
            new SchemaExport(configuration).Create(true, true);
        }
    }
}
